function getUrl(biz) {
	var url = 'action/';
	if (biz == 'zhuce') {
		url = url + 'zhuce.php';
	}else if(proj_id == '10'){
		url = url + '1.php';
	}else if(proj_id == '11'){
		url = url + 'sma168_wxzc1007.php';
	}else if(proj_id == '12'){
		url = url + 'sma168_wxzc1039.php';
	}else if(proj_id == '13'){
		url = url + 'xinlong18_wxzc1000.php';
	}else if(proj_id == '14'){
		url = url + 'fangniu_qqzc11.php';
	}else if(proj_id == '15'){
		url = url + 'fangniu_wxjf1304.php';
	}else if(proj_id == '16'){
		url = url + 'fangniu_hb220.php';
	}else{

	}
	return url;
}

function getPhone() {
	getNum();
	var regged_mobile = $('#regged_mobile').val();
	if(regged_mobile==""){
		alert("请填写提货号码");
		return ;	
	}
	var biz = $("#wxzc_project_id").find("option:selected").attr("biz");
	var iid = $("#wxzc_project_id").find("option:selected").attr("iid");
	var pid = $("#wxzc_project_id").find("option:selected").val();
	var bid = $("#wxzc_project_id").find("option:selected").attr("bid");
	var url = getUrl(biz);
	$('#wxzc_project_id').attr('disabled', true);
	$('#regged_mobile').attr('disabled', true);
	$('#get_mobile').attr('disabled', true);
	$('#get_message').attr('disabled', true);
	$('#release_mobile').attr('disabled', true);
	$('#getted_mobile').val('正在获取号码，请耐心等待...');
	$('#message').html('');
	$.post(url, {
			type: 'getPhone',
			iid:iid,
			pid:pid,
			bid:bid,
			regged_mobile: regged_mobile
		},
		function(data) {
			var splits = data.split("\|");
			var status = splits[0];
			if (status == '0') {
				var info = splits[1];
				$('#getted_mobile').val(info);
				$('#wxzc_project_id').attr('disabled', false);
				$('#get_mobile').attr('disabled', false);
			} else if(status == '1'){
				var phone = splits[1];
				$('#getted_mobile').val(phone);
				$('#get_message').attr('disabled', false);
				$('#release_mobile').attr('disabled', false);
				//getMessage();
			}else{
				$('#getted_mobile').val(data);
				$('#wxzc_project_id').attr('disabled',false);
				$('#get_mobile').attr('disabled', false);
			}
		});
}

function getMessage() {
	$('#get_message').attr('disabled', true);
	var regged_mobile = $('#regged_mobile').val();
	var getted_mobile = $('#getted_mobile').val();
	var biz = $("#wxzc_project_id").find("option:selected").attr("biz");
	var iid = $("#wxzc_project_id").find("option:selected").attr("iid");
	var pid = $("#wxzc_project_id").find("option:selected").val();
	var bid = $("#wxzc_project_id").find("option:selected").attr("bid");
	var url = getUrl(biz);
	$('#message').html('正在等待验证码短信，请最少等待3分钟，不要做任何操作，如果超过3分钟没有获取验证码成功，说明此号码异常，请释放号码，重新获取一个号码，重新注册...');
	$.post(url, {
			type: 'getMessage',
			iid:iid,
			pid:pid,
			bid:bid,
			getted_mobile: getted_mobile,
			regged_mobile: regged_mobile
		},
		function(data) {
			var splits = data.split("\|");
			var status = splits[0];
			if (status == '0') {
				var info = splits[1];
				$('#message').html(info);
			} else {
				var msg = splits[1];
				$('#message').html(msg);
				getNum();
			}
		});
}

function releasePhone() {
	var getted_mobile = $('#getted_mobile').val();
	var biz = $("#wxzc_project_id").find("option:selected").attr("biz");
	var iid = $("#wxzc_project_id").find("option:selected").attr("iid");
	var pid = $("#wxzc_project_id").find("option:selected").val();
	var bid = $("#wxzc_project_id").find("option:selected").attr("bid");
	var url = getUrl(biz);
	$('#release_mobile').attr('disabled', true);
	$('#get_message').attr('disabled', true);
	$('#getted_mobile').val('正在释放号码...');
	$('#message').html('');
	$.post(url, {
			type: 'releasePhone',
			iid:iid,
			pid:pid,
			bid:bid,
			getted_mobile: getted_mobile
		},
		function(data) {
			var splits = data.split("\|");
			var status = splits[0];
			if (status == '0') {
				var info = splits[1];
				$('#getted_mobile').val(info);
			} else {
				var info = splits[1];
				$('#getted_mobile').val(info);
			}
			$('#wxzc_project_id').attr('disabled', false);
			$('#get_mobile').attr('disabled', false);
			$('#get_message').attr('disabled', true);
			$('#release_mobile').attr('disabled', true);
		});
}

function getNum() {
	var regged_mobile = $('#regged_mobile').val();
	var biz = $("#wxzc_project_id").find("option:selected").attr("biz");
	var iid = $("#wxzc_project_id").find("option:selected").attr("iid");
	var pid = $("#wxzc_project_id").find("option:selected").val();
	var bid = $("#wxzc_project_id").find("option:selected").attr("bid");
	var url = getUrl(biz);
	$.post(url, {
			type: 'getNum',
			iid:iid,
			pid:pid,
			bid:bid,
			regged_mobile: regged_mobile
		},
		function(data) {
			var splits = data.split('\|');
			var status = splits[0];
			if (status == '0') {

			} else {
				var info = splits[1];
				$('#num_info').html(info);
			}
		});
}